﻿<%@ Page Title="Cungmuanao.com - Quản lý Banner" Language="C#" MasterPageFile="~/Admin/Admin.master" 
    AutoEventWireup="true" ValidateRequest="false" CodeFile="ManagePartners.aspx.cs" Inherits="Admin_ManagePartners" %>
<%@ Import Namespace="DTO" %>
<%@ Register src="../Controls/FileUpload.ascx" tagname="FileUpload" tagprefix="uc1" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

<script type="text/javascript" src="../js/nicEdit.js"></script>
<script type="text/javascript">
    bkLib.onDomLoaded(function () {
        nicEditors.allTextAreas()
    });
</script>

    <div class="title">Quản lý Banner</div>
    <div class="body">
    
    <asp:Label runat="server" ID="lbldepartments" Text="chọn vị trí : " />
    <asp:DropDownList runat="server" ID="ddlPartnerCat" 
        AutoPostBack="true" Width="100px"
        onselectedindexchanged="ddlPartnerCat_SelectedIndexChanged">
        <asp:ListItem Text="Cột phải" Value="2" Selected="True"></asp:ListItem>
        <asp:ListItem Text="Cột trái" Value="3"></asp:ListItem>
    </asp:DropDownList>
    
<asp:GridView runat="server" ID="gvwPartners" Width="100%"
        AutoGenerateColumns="False" DataSourceID="objAllPartners" DataKeyNames="ID"
        AllowPaging="True" EmptyDataText="<b>Image/Flash nào</b>"
        onrowcreated="gvwPartners_RowCreated" 
        onrowdeleted="gvwPartners_RowDeleted" 
        onselectedindexchanged="gvwPartners_SelectedIndexChanged" 
            onrowdatabound="gvwPartners_RowDataBound">
    <Columns >
         <asp:TemplateField HeaderText="STT" >
            <ItemStyle HorizontalAlign="Center" Width="20" />
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblSTT" Text='<%#Container.DataItemIndex + 1 %>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Tiêu đề">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblTitle" Text='<%#Eval("Title")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Image/Flash">
            <ItemTemplate>
                 <asp:HyperLink runat="server" ID="hplLogo" Target="_blank" Width="194px" NavigateUrl='<% #Eval("Logo") %>' Visible='<%# Eval("Option").ToString() == "0" %>' >
                    <asp:Image runat="server" ID="imglogo" ImageUrl='<% #Eval("Logo") %>' Width="194px" />
                </asp:HyperLink>
                 <asp:HyperLink runat="server" ID="hplFlash" Target="_blank" Width="194px" NavigateUrl='<% #Eval("Logo") %>' Visible='<%# Eval("Option").ToString() == "1" %>'>
                    <object><embed src='<%#Eval("Logo") %>' width="194px" height="220px" quality="high" 
                        pluginspage="http://www.macromedia.com/go/getflashplayer" 
                        type="application/x-shockwave-flash" menu="false" 
                        wmode="transparent">
                    </embed></object>
                    </asp:HyperLink>
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Mức độ">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblimportance" Text='<%#Eval("Importance")%>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="website">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblwebsite" Text='<%#Eval("Website")%>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Ghi chú">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lbldescription" Text='<%#Eval("Description")%>' />
            </ItemTemplate>
        </asp:TemplateField>                
        
        <asp:CommandField HeaderText="Edit" ButtonType="Image" SelectImageUrl="~/Images/edit.gif"
                SelectText="Edit" ShowSelectButton="True">
                <ItemStyle HorizontalAlign="Center" Width="20" />
        </asp:CommandField>
        
        <asp:CommandField HeaderText="Delete" ButtonType="Image" DeleteImageUrl="~/Images/delete.gif"
                DeleteText="Delete" ShowDeleteButton="True">
                <ItemStyle HorizontalAlign="Center" Width="20" />
            </asp:CommandField>
    </Columns>
 </asp:GridView>
 
        <asp:ObjectDataSource ID="objAllPartners" runat="server" 
            DeleteMethod="DeletePartner" SelectMethod="GetBannerByPartnerCatID" 
            TypeName="BLL.Pages.Partners">
            <DeleteParameters>
                <asp:Parameter Name="id" Type="Int32" />
            </DeleteParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlPartnerCat" Name="partnerCatID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
 
<p></p>

<asp:DetailsView runat="server" ID="dvwCurrPartner" DefaultMode="Insert"
        AutoGenerateRows="False" DataKeyNames="ID" Width="100%" 
            AutoGenerateInsertButton="True" AutoGenerateEditButton="True" 
    DataSourceID="objCurrPartner" onitemcommand="dvwCurrPartner_ItemCommand" 
        oniteminserted="dvwCurrPartner_ItemInserted" 
        onitemupdated="dvwCurrPartner_ItemUpdated">
    <Fields>
        <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="true" InsertVisible="false"
               SortExpression="ID" />
         <asp:BoundField DataField="AddedDate" HeaderText="Ngày t&#7841;o" InsertVisible="False"
            ReadOnly="True" SortExpression="AddedDate" />
         <asp:BoundField DataField="AddedBy" HeaderText="Ng&#432;&#7901;i t&#7841;o" InsertVisible="False" ReadOnly="True"
            SortExpression="AddedBy" />                
        <asp:TemplateField HeaderText="Tiêu đề">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtName" Text='<%#Bind("Title") %>' Width="99%" />
                <asp:RequiredFieldValidator ID="valRequireName" runat="server" ControlToValidate="txtName" SetFocusOnError="true"
                  Text="Bắt buộc nhập tiêu đề" ToolTip="Bắt buộc nhập tiêu đề" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Đường dẫn file">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtLogo" Text='<%#Bind("Logo") %>' Width="99%" Enabled="false"/>
                <asp:RequiredFieldValidator ID="valRequireLogo" runat="server" ControlToValidate="txtLogo" SetFocusOnError="true"
                  Text="Bắt buộc nhập logo/hình ảnh" ToolTip="Bắt buộc nhập logo/hình ảnh" Display="Dynamic"></asp:RequiredFieldValidator>                
            </EditItemTemplate>
        </asp:TemplateField>                        
        
        <asp:TemplateField HeaderText="Vị trí">
            <ItemTemplate>
                <asp:Label runat="server" ID="lblPartnerCat" Text='<%#Eval("PartnerCatID") %>' />
            </ItemTemplate>        
            <EditItemTemplate>
            <asp:DropDownList runat="server" ID="ddlPartnerCat" Width="100px"
                SelectedValue='<%# Bind("PartnerCatID") %>'
                onselectedindexchanged="ddlPartnerCat_SelectedIndexChanged">
                <asp:ListItem Text="Cột phải" Value="2" Selected></asp:ListItem>
                <asp:ListItem Text="Cột trái" Value="3"></asp:ListItem>
            </asp:DropDownList>                   
            </EditItemTemplate>
        </asp:TemplateField>        

        <asp:TemplateField HeaderText="Image/Flash" >
            <EditItemTemplate>
                <asp:RadioButtonList ID="rbtOption" runat="server" SelectedValue='<%#Bind("Option") %>' RepeatDirection="Horizontal" >
                    <asp:ListItem Text="Image" Value="0" Selected="True" />
                    <asp:ListItem Text="Flash" Value="1" />
                </asp:RadioButtonList>
            </EditItemTemplate>
        </asp:TemplateField> 

        <asp:TemplateField HeaderText="Mức độ">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtNumber" Text='<%#Bind("Importance") %>' Width="99%" />
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Website">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtWebsite" Text='<%#Bind("Website") %>' Width="99%" />
            </EditItemTemplate>
        </asp:TemplateField>
        
        <%--<asp:TemplateField HeaderText="Ghi chú">
            <EditItemTemplate>
            <asp:TextBox ID="FCKeditor1" runat="server" Text='<%# Bind("Description") %>' Rows="20" TextMode="MultiLine" Width="100%" MaxLength="4000"></asp:TextBox>                             
            </EditItemTemplate>
        </asp:TemplateField>--%>
    </Fields>
    </asp:DetailsView>
    
    <asp:ObjectDataSource runat="server" ID="objCurrPartner" TypeName="BLL.Pages.Partners" SelectMethod="GetPartner" 
    InsertMethod="InsertPartner" UpdateMethod="UpdatePartnerOption">
        <SelectParameters>
            <asp:ControlParameter PropertyName="SelectedValue" ControlID="gvwPartners" Type="Int32" Name="PartnerID" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="logo" Type="String" />
            <asp:Parameter Name="importance" Type="Int32" />
            <asp:Parameter Name="website" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="partnerCatID" Type="Int32" />
            <asp:Parameter Name="Option" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="logo" Type="String" />
            <asp:Parameter Name="importance" Type="Int32" />
            <asp:Parameter Name="website" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="partnerCatID" Type="Int32" />
            <asp:Parameter Name="Option" Type="Int32" />
        </UpdateParameters>
    </asp:ObjectDataSource>


    <p style="color: #FF0000">
        Hướng dẫn upload Flash file : Để website được hiển thị tốt và đầy đủ chỉ upload 
        những flahs có kích thước đúng 194 x 220.</p>
    <uc1:FileUpload ID="FileUpload1" runat="server" />
    </div>
    <div class="bottom"></div>
</asp:Content>

